package demo.day14

// 懒汉式单例的实现 Kotlin版本
class SingletonDemo2Kt{
    companion object{
        private var instance: SingletonDemo2Kt? = null
            get() {
                if (field == null){
                    field = SingletonDemo2Kt()
                }
                return field
            }
        fun getInstanceAction():SingletonDemo2Kt = instance!!
    }

    fun show(){
        println("show函数被调用了")
    }
}

fun main() {
    SingletonDemo2Kt.getInstanceAction().show()
}